<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>

	<style type="text/css">
.ui-layout-north {
	z-index: 20 !important;
	overflow: visible !important;;
}

.ui-layout-north .ui-layout-unit-content {
	overflow: visible !important;
}

.ui-widget {
	font-size: 10px !important;
}

.size {
	width: 550px;
	position: relative;
	left: 30%;
	top: 10%;
}

.centro {
	top: 50%
}

.tabela {
	width: 750px;
}
</style>
	<title>Cadastro de Topografia</title>
</h:head>

<h:body>
	<ui:decorate template="/templateBase.xhtml">
		<ui:define name="center">
			<p:growl id="growl" life="3000" autoUpdate="true" />
			<h:form prependId="true" id="formCadastroTopografia">
				<p:hotkey bind="f4" oncomplete="dlg.show()"
					actionListener="#{topografiaBacking.carregarTopografia}"
					update=":formPesquisa:tabelaTopografia" upprocess="@all"
					immediate="true" />

				<br />
				<br />
				<br />
				<br />
				<p:panel header="Cadastro de Topografia" styleClass="size"
					toggleable="true"
					footer="SIGLAS - Sistema de Gerenciamento de Laboratório de Análise de Solo">

					<br />
					<div align="center">
						<h:panelGrid columns="3">
							<h:outputText value="Descrição: " />
							<p:inputText
								value="#{topografiaBacking.topografiaSalvar.descricao}"
								size="50" required="true"
								requiredMessage="Informe a topografia!" />
							<p:commandButton value="F4" icon="ui-icon-search"
								oncomplete="dlg.show()"
								actionListener="#{topografiaBacking.carregarTopografia}"
								update=":formPesquisa:tabelaTopografia" upprocess="@all"
								immediate="true" />
						</h:panelGrid>
					</div>
					<br />

					<div align="center">
						<h:panelGrid columns="2">
							<p:commandButton value="Salvar" update=":formCadastroTopografia"
								icon="ui-icon-disk" actionListener="#{topografiaBacking.salvar}" />
							<p:commandButton value="Cancelar" icon="ui-icon-cancel"
								actionListener="#{topografiaBacking.reset}" ajax="false" />
						</h:panelGrid>
					</div>
				</p:panel>
			</h:form>
			<h:form id="formPesquisa">
				<p:dialog id="pesquisaTopografia" widgetVar="dlg" appendToBody="true" modal="true"
					header="Pesquisar Topografia" closable="true" resizable="false"
					showEffect="clip" hideEffect="clip">

					<p:dataTable id="tabelaTopografia" var="top"
						value="#{topografiaBacking.listaTopografia}" paginator="true"
						rows="5">
						<f:facet name="header">
							<h:outputText value="Topográfias Cadastradas" />
						</f:facet>

						<p:column headerText="Código">
							<h:outputText value="#{top.codigoFormatado()}" />
						</p:column>

						<p:column headerText="Descrição">
							<h:outputText value="#{top.descricao}" />
						</p:column>
						<p:column headerText="Ações">
							<div align="center">
								<h:panelGrid columns="2">
									<p:commandButton icon="ui-icon-pencil" onclick="dlg.hide()"
										ajax="false" action="#{topografiaBacking.prepapraAlteracao}">
										<f:setPropertyActionListener
											target="#{topografiaBacking.topografiaSelecionada}"
											value="#{top}" />
									</p:commandButton>

									<p:commandButton icon="ui-icon-close"
										onclick="dlgDelete.show()">
										<f:setPropertyActionListener
											target="#{topografiaBacking.topografiaSelecionada}"
											value="#{top}" />
									</p:commandButton>

								</h:panelGrid>
							</div>
						</p:column>

					</p:dataTable>
				</p:dialog>
				<p:dialog id="confirmaDelete" widgetVar="dlgDelete"
					header="Deletar Registro" closable="true" width="230"
					resizable="false" showEffect="clip" hideEffect="clip">
					<div align="center">
						<h:outputText value="Deseja realmente excluir esse registro?" />
						<h:panelGrid columns="2">
							<p:commandButton value="Sim" onsuccess="dlgDelete.hide()"
								actionListener="#{topografiaBacking.delete}"
								update=":formPesquisa:pesquisaTopografia, :formCadastroTopografia"
								process="@all" immediate="true" />
							<p:commandButton value="Não" onclick="dlgDelete.hide()" />
						</h:panelGrid>
					</div>
				</p:dialog>
			</h:form>

		</ui:define>
	</ui:decorate>
</h:body>
</html>